import request from '@/config/axios'

// 权限配置(必须) VO
export interface AccessVO {
  id: number // id
  debug: number // 是否为 DEBUG 调试数据，只允许在开发环境使用，测试和线上环境禁用：0-否，1-是。
  accessSchema: string // 数据库名/模式
  name: string // 实际表名，例如 apijson_user
  alias: string // 外部调用的表别名，例如 User，前端传参示例 { "User":{} }
  detail: string // 描述
}

export interface AccessAllDataRespVO {
  alias: string
  get:boolean, head:boolean, gets:boolean, heads:boolean, post:boolean, put:boolean, delete:boolean, crud:boolean,
  methodsBool:boolean
}

// 权限配置(必须) API
export const AccessApi = {
  // 查询权限配置(必须)分页
  getAccessPage: async (params: any) => {
    return await request.get({ url: `/apijson/access/page`, params })
  },

  // 查询权限配置(必须)详情
  getAccess: async (id: number) => {
    return await request.get({ url: `/apijson/access/get?id=` + id })
  },

  // 新增权限配置(必须)
  createAccess: async (data: AccessVO) => {
    return await request.post({ url: `/apijson/access/create`, data })
  },

  // 修改权限配置(必须)
  updateAccess: async (data: AccessVO) => {
    return await request.put({ url: `/apijson/access/update`, data })
  },

  // 删除权限配置(必须)
  deleteAccess: async (id: number) => {
    return await request.delete({ url: `/apijson/access/delete?id=` + id })
  },

  // 导出权限配置(必须) Excel
  exportAccess: async (params) => {
    return await request.download({ url: `/apijson/access/export-excel`, params })
  },
  //获取所有权限
  getAllAccess: async (params) => {
    return await request.get({ url: `/apijson/access/getAllAccess`, params })
  }
}
